
package com.shms.service.impl;


import java.util.List;

import com.shms.bean.GroupOfHome;
import com.shms.dao.ShHomeDao;
import com.shms.service.ShHomeService;
import com.shms.entity.ShHome;
import com.shms.entity.ShPoint;

public class ShHomeServiceImpl implements ShHomeService {

	private ShHomeDao shHomeDao;
	public void setShHomeDao(ShHomeDao shHomeDao) {
		this.shHomeDao = shHomeDao;
	}
	@Override
	public GroupOfHome queryHome(GroupOfHome groupOfHome) {
		if (groupOfHome.getType().equals("forward")) {
			int currentPage = groupOfHome.getCurrentPage() - 2;
			groupOfHome.setCurrentPage(currentPage);
		}
		return shHomeDao.queryHome(groupOfHome);
	}
	@Override
	public boolean batchDelete(Integer[] nos) {
		return this.shHomeDao.batchDelete(nos);
	}
	public List<ShHome> queryHomeByBid(long id) {
		return shHomeDao.queryHomeByBid(id);
	}	
	
	public boolean saveHome(ShHome shHome) {
		boolean rtn = true;
		if (shHome.getHid() == 0) {
			rtn = shHomeDao.saveHome(shHome);
		} else {
			rtn = shHomeDao.updateHome(shHome);
		}
		return rtn;
	}
	
	public ShHome queryById(ShHome shHome) {
		return shHomeDao.queryById(shHome);
	}
	@Override
	public List<ShPoint> queryPointsByHId(ShHome shHome) {
		return shHomeDao.queryPointsByHId(shHome);
	}
}
